
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
The ktx-parse npm package is a utility for parsing KTX (Khronos Texture) files, which are used for storing textures in a standardized format. This package allows developers to read and manipulate KTX files in JavaScript, making it useful for applications that need to handle texture data, such as game engines, 3D rendering applications, and other graphics-related software.
Parsing KTX Files
This feature allows you to parse a KTX file and extract its contents. The code sample demonstrates how to read a KTX file from the filesystem and parse it using the ktx-parse package.
const ktxParse = require('ktx-parse');
const fs = require('fs');
const ktxData = fs.readFileSync('path/to/texture.ktx');
const parsedKTX = ktxParse(ktxData);
console.log(parsedKTX);
Accessing Texture Data
This feature allows you to access the raw texture data from a parsed KTX file. The code sample shows how to extract the texture data from the first mip level of the parsed KTX file.
const ktxParse = require('ktx-parse');
const fs = require('fs');
const ktxData = fs.readFileSync('path/to/texture.ktx');
const parsedKTX = ktxParse(ktxData);
const textureData = parsedKTX.levels[0].levelData;
console.log(textureData);
Extracting Metadata
This feature allows you to extract metadata from a KTX file. The code sample demonstrates how to read the key-value metadata pairs from a parsed KTX file.
const ktxParse = require('ktx-parse');
const fs = require('fs');
const ktxData = fs.readFileSync('path/to/texture.ktx');
const parsedKTX = ktxParse(ktxData);
const metadata = parsedKTX.keyValue;
console.log(metadata);
The ktx package is another utility for working with KTX files. It provides similar functionality to ktx-parse, including parsing and manipulating KTX files. However, ktx-parse is often preferred for its simplicity and ease of use.
The three package is a popular 3D library that includes support for loading and using KTX textures. While it offers a broader range of features for 3D rendering, it may be more complex to use if you only need to work with KTX files.
The gl-texture2d package is a WebGL utility for handling 2D textures, including KTX files. It provides functionality for creating and managing textures in WebGL, making it a good choice for web-based graphics applications.
KTX 2.0 (.ktx2) parser and serializer.
Install:
npm install --save ktx-parse
Import:
import { read, write } from 'ktx-parse';
Usage:
// Parse texture container from file:
const container = read(data /* ← Uint8Array or Buffer */);
// Write texture container to file:
const data = write(container); // → Uint8Array
See API documentation for more details:
KTX-Parse reads/writes KTX 2.0 containers, and provides access to the compressed texture data within the container. To decompress that texture data, or to compress existing texture data into GPU texture formats used by KTX 2.0, you'll need to use additional libraries such as encoders or transcoders.
Encoding:
Encoding GPU textures is a slow process, and should be completed at development/authoring time so that the compressed texture can be transmitted to the viewing device. GPU textures require much less GPU memory than image formats like PNG or JPEG, and can be uploaded to the GPU quickly with less impact on framerate. GPU textures can also have smaller filesizes in many, but not all, cases. See the Basis documentation for details on this process.
The following tools may be used to produce Basis Universal compressed textures in KTX 2.0 (.ktx2
) containers, which ktx-parse
can then read or edit:
Transcoding / Decoding:
Basis Universal texture formats (ETC1S and UASTC) cannot be directly read by a GPU, but are designed to be very efficiently rewritten into many of the specific GPU texture formats that different GPUs require. This process is called transcoding, and typically happens on the viewing device after a target output format (e.g. ETC1, ASTC, BC1, ...) is chosen. These transcoders can also fully decode texture data to uncompressed RGBA formats, if raw pixel data is required.
ktx-parse
first, then transcode the mip levels using a low-level transcoder. Only UASTC texture formats currently supported.FAQs
KTX 2.0 (.ktx2) parser and serializer.
The npm package ktx-parse receives a total of 197,436 weekly downloads. As such, ktx-parse popularity was classified as popular.
We found that ktx-parse demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.